{__NOLAYOUT__}
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>{$activity.name}</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="msapplication-tap-highlight" content="no">
		<meta content="telephone=no" name="format-detection">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Static/css/simui.mobile.css?10111121" />
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Static/css/sim-icon.css?10111121" />
		<script src="__PUBLIC__/Static/js/zepto.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="__PUBLIC__/Static/js/simapp.js?3" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			.activity-desc {
				padding: 10px;
				margin-bottom: 10px;
				background-color: #def;
				text-align: left;
				font-size: 14px;
			}
			.vote-list {
				background-color: #fff;
				border-radius: 5px;
				text-align: center;
				padding: 1px;
				margin-bottom: 20px;
				box-sizing: border-box;
				width: 49%;
				float: left;
			}
			.vote-list:nth-child(odd){
			    margin-left: 2%;
			    clear: right;
			}
			.vote-list:nth-child(even){
			    clear: left;
			}
			.vote-list img {
				width: 100%;
			}
			.vote-desc {
				color: #999;
				padding: 3px;
				font-size: 75%;
				border: #999 dashed 1px;
				margin: 10px;
			}
			.vote-check {
				color: #eee;
			}
			.vote-select {
				color: #060;
			}
			.sim-footer {
				background-color: #def;
			}
			.vote-action {
				height: 32px;
				line-height: 32px;
				padding: 0 3px;
			}
		</style>
	</head>

	<body>
		<!-- 导航菜单 -->
		<div class="sim-header sim-bg sim-bg-royal inset">
			<span>{$activity.name}</span>
		</div>
		<div class="sim-body">
			<div class="sim-page inset">
				<div class="activity-desc">
				    {$activity.desc}
				    <notempty name="activity.ruleTitle"><div class="sim-text-right"><a href="__CONTROLLER__/rule/cid/{$activity.cid}/aid/{$activity.id}">{$activity.ruleTitle}</a></div></notempty>
				</div>
				<volist name="options" id="vo">
					<div class="vote-list" data-id="{$vo.id}">
						<h4 class="vote-title">{$vo.name}</h4>
						<div class="vote-desc">{$vo.desc}</div>
						<img src="{$vo.pic}" />
						<div class="vote-action">
							<span class="sim-float-right"><i class="vote-check icon-check-circle-o"></i> 选ta</span>
							<span class="sim-float-left">得票 <span class="sim-badge sim-badge-royal">{$vo['voteCount'] + $activity['defaultCount']}</span></span>
						</div>
					</div>
				</volist>
			</div>
		</div>
		<div class="sim-footer">
			<ul class="sim-equal">
				<empty name="ticket">
					<li class="sim-text-left sim-padding-left">
						您选择了 <span id="label-select" class="sim-label sim-label-royal"></span>
					</li>
					<li>
						<button id="btn-vote" class="sim-btn sim-btn-primary">确认投票</button>
					</li>
					<else />
					<li class="sim-text-left sim-padding-left">
						您投给了 <span id="label-select" class="sim-label sim-label-royal">{$ticket.name}</span>
					</li>
					<li>
						<button id="btn-vote" class="sim-btn sim-btn-primary sim-disabled">已经投票</button>
					</li>
				</empty>
			</ul>
		</div>
		<script type="text/javascript">
			var selectId;
			var selectName;
			$(function() {
				$(".vote-list").click(function() {
					$(".vote-list .vote-check").removeClass("vote-select");
					$(this).find(".vote-check").addClass("vote-select");
					selectId = $(this).attr("data-id");
					selectName = $(this).find(".vote-title").text();
					simapp.toast("您选中了 " + selectName);
					$("#label-select").text(selectName);
				});
				$("#btn-vote").click(function() {
					$btn = $(this);
					if (selectId == null) {
						simapp.toast("您还没有选择~");
						return false;
					}
					$.ajax({
						type: "POST",
						url: "__CONTROLLER__/ajaxVote?debug",
						async: true,
						data: {
							cid: "{$activity.cid}",
							aid: "{$activity.id}",
							uid: "{$userInfo.id}",
							oid: selectId
						},
						beforeSend: function() {
							$btn.attr("disabled", true);
							simapp.toast("正在提交投票~");
						},
						success: function(res) {
							simapp.toast(res.msg);
						},
						error: function() {
							simapp.toast("网络错误，请重试！");
						},
						complete: function() {
							$btn.removeAttr("disabled");
						}
					});
				})
			})
		</script>
	</body>

</html>